package com.example.eurekaserver.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

// 在客户端应用中添加刷新端点
@RestController
@RefreshScope
public class RegistryRefreshController {

    @Autowired
    private DiscoveryClient discoveryClient;

    @PostMapping("/force-refresh")
    public String refresh() {
        discoveryClient.getServices(); // 强制刷新
        return "Registry refreshed";
    }
}